package org.example.service;

import org.dom4j.DocumentException;
import org.example.entity.Movie;
import org.example.entity.Ticket;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author TonySong
 * @date 2025/7/28 0028
 * @time 17:03
 */
public interface ICinemaService {

      Map<String, Movie> MOVIE_MAP=new HashMap<>();
      File FILE =new File("movies.xml");

      File SEAL_TICKETS_FILE= new File("seal_tickets.dat");
      List<Ticket> SEAL_TICKETS=new ArrayList<>(20);

    /**
     * 读取xml文件到map集合中
     * @throws IOException
     */
    Map<String,Movie> readXmlToMap() throws IOException, DocumentException, ParseException;

    /**
     * 浏览所有电影
     */
    void showMovies();

    /**
     * 根据电影名获取电影对象：用于购票
     * @param name
     * @return
     */
    Movie getMovieByName(String name);

    /**
     * 添加票到销售集合中
     * @param ticket
     */
    void addTickets(Ticket ticket);

    /**
     * 序列化销售记录
     */
    void saveTickets() throws IOException;

    /**
     * 反序列化销售记录
     * @return
     */
    List<Ticket> loadTickets() throws IOException, ClassNotFoundException;

    /**
     * 查询销售记录
     */
    void showSealTickets();
}
